﻿function kyoubai(){
var fels = document.getElementsByName("cw");
var fel;
if (fels.length == 0) {
fel = document;
} else {
fel = fels[0].contentWindow.document;
}
var form = fel.getElementsByTagName("form")[2];
var newform = fel.createElement("form");
var input1 = fel.createElement("input");
input1.id = "itemname";
input1.type = "text";
var input2 = fel.createElement("input");
input2.id = "syuppinname";
input2.type = "text";
var input3 = fel.createElement("input");
input3.type = "button";
input3.value = "絞り込み";
input3.onclick = new Function("parent.sibori();return;");
newform.appendChild(fel.createTextNode("アイテム名"));
newform.appendChild(input1);
newform.appendChild(fel.createTextNode("出品者名"));
newform.appendChild(input2);
newform.appendChild(input3);
form.parentNode.insertBefore(newform,form);
}
function sibori(){
var fels = document.getElementsByName("cw");
if (fels.length == 0) {
fel = document;
} else {
fel = fels[0].contentWindow.document;
}
var input1 = fel.getElementById("itemname").value;
var input2 = fel.getElementById("syuppinname").value;

var table = fel.getElementsByTagName("table")[4];
var trs = table.getElementsByTagName("tr");
for (i=1;i<trs.length;i++) {
var itemn = trs[i].childNodes[0].innerHTML;
var syuppin = trs[i].childNodes[4].innerHTML;
var b = true;
if (input1 != "") {
var m = itemn.match(new RegExp(input1));
if (m == null) {
b = false;
}
}
if (input2 != "") {
var m = syuppin.match(new RegExp(input2));
if (m == null) {
b = false;
}
}
if (!b) {
trs[i].parentNode.removeChild(trs[i]);
i--;
}
}
}
kyoubai();